using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class fj : MonoBehaviour
{
public GameObject zd;
Vector3 playbugposition = new Vector3(20, -10, 10);
Vector3 playbugRotation = new Vector3(0, 0, 90);
public Vector3 playerInput;
public float spawnTime = 1;
public float timeBetween = 0;
public float health;
public float Diedtime;
public double qwq;

public static double awa; 

    // Start is called before the first frame update
    void Start()
    { 
      awa = 10;
    }

    // Update is called once per frame
    private void Update()
    {  
       
       if(awa < 1)
       {
         Destroy(gameObject,Diedtime);
       } 

        
        Vector3 dis = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        dis.z = this.transform.position.z;
        this.transform.position = dis;
        Debug.Log(dis);
        this.transform.position= Vector3.Lerp(this.transform.position,dis,Time.deltaTime);
        this.transform.position = Vector3.MoveTowards(this.transform.position, dis, Time.deltaTime);
        Vector3 speed = Vector3.zero;
        this.transform.position = Vector3.SmoothDamp(this.transform.position, dis,ref speed, 0.1f);
        Debug.Log(speed);

        {
            timeBetween += Time.deltaTime;
            if (timeBetween > spawnTime)
            {
                Instantiate(zd, transform.position, Quaternion.identity);
                timeBetween = 0;
            }
        }
    }
}
